package org.kaindorf.kainflix.metadata;

import org.kaindorf.kainflix.metadata.repository.CustomerRepository;
import org.kaindorf.kainflix.metadata.repository.ProductRepository;
import org.kaindorf.kainflix.metadata.repository.entity.Customer;
import org.kaindorf.kainflix.metadata.repository.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@Profile("dev")
public class DemoConfigurer {

    @Autowired
    private ProductRepository productRepository;
    @Autowired
    private CustomerRepository customerRepository;

    @PostConstruct
    public void createDemoData() {
        Product product1 = new Product();
        product1.setName("Product A");
        productRepository.save(product1);

        Product product2 = new Product();
        product2.setName("Product B");
        productRepository.save(product2);

        Product product3 = new Product();
        product3.setName("Product C");
        productRepository.save(product3);

        Customer customer1 = new Customer(10, "Manuel", "Banane");
        customerRepository.save(customer1);

        Customer customer2 = new Customer(10, "Thomas", "Kartoffel");
        customerRepository.save(customer1);
    }

}
